#ifndef __TSINGLETON_H__
#define __TSINGLETON_H__

#pragma once


template<class T>
class TSingleton
{
protected:
	TSingleton()
	{
	}
	~TSingleton()
	{
	}
public:
	static BOOL Initialize()
	{
		_Instance = new T;
		return ( _Instance != NULL );
	}

	static T* Instance()
	{
		return _Instance;
	}

	static void Deinitialize()
	{
		if(_Instance != NULL)
		{
			delete _Instance;
			_Instance = NULL;
		}
	}

private:
	static T* _Instance;	
};
template<class T>
T* TSingleton<T>::_Instance = NULL;

#endif // __TSINGLETON_H__
